package com.kaver.sso.web.controller.rest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kaver.sso.def.Result;
import com.kaver.sso.def.dto.DeptDto;
import com.kaver.sso.def.req.AddDeptReq;
import com.kaver.sso.def.req.DelDeptReq;
import com.kaver.sso.def.req.DeptListReq;
import com.kaver.sso.def.req.DeptPageListReq;
import com.kaver.sso.def.req.UpdateDeptReq;
import com.kaver.sso.def.resp.PageResp;
import com.kaver.sso.service.DeptService;

/**  
* @ClassName: DeptController  
* @Description: 部门
* @author roc  
* @date Aug 6, 2021 3:58:32 PM  
*    
*/
@RestController
@RequestMapping("/api/dept")
public class DeptController {
    @Autowired
    DeptService deptService;
    /**
     * 添加部门
     */
    @PostMapping("/addDept")
    public Result<Void> addDept(@RequestBody AddDeptReq req) {
        deptService.addDept(req);
        return Result.createSuccess();
    }
    
    /**
     * 删除部门
     */
    @PostMapping("/delDept")
    public Result<Void> delDept(@RequestBody DelDeptReq req) {
        deptService.delDept(req);
        return Result.createSuccess();
    }
    /**
     * 更新部门
     */
    @PostMapping("/updateDept")
    public Result<Void> updateDept(@RequestBody UpdateDeptReq req) {
        deptService.updateDept(req);
        return Result.createSuccess();
    }
    
    /**
     * 部门列表分页查询
     */
    @PostMapping("/deptPageList")
    public Result<PageResp<DeptDto>> deptPageList(@RequestBody DeptPageListReq req) {
        return Result.createSuccess(deptService.deptPageList(req));
    }
    /**
     * 部门列表查询
     */
    @PostMapping("/deptList")
    public Result<List<DeptDto>> deptList(@RequestBody DeptListReq req) {
        return Result.createSuccess(deptService.deptList(req));
    }
}
